< Prev(J) / Next(K) > / View :

Filename: /text/sbasic/shared/03020409.xhp

(section: getattr) (bookmark: bm_id3150984)
GetAttr function

GetAttr 関数

GetAttr Function [Runtime]
GetAttr 関数 [実行時](hd_id3150984.1)

Returns a bit pattern that identifies the file type or the name of a volume or a directory.
ボリュームやディレクトリの名前ないしファイルのタイプを示すビットパターン情報を取得して返します。(par_id3154347.2)

(/section: getattr)

Syntax:
構文:(hd_id3149457.3)

GetAttr (Text As String)
GetAttr (Text As String)(par_id3150359.4)

Return value:
戻り値:(hd_id3151211.5)

Integer
整数(par_id3154909.6)

Parameters:
パラメータ:(hd_id3145172.7)

Text: Any string expression that contains an unambiguous file specification. You can also use URL notation.
Text: ファイルの位置を明示的に指定した文字列表式。またURL 指定を用いることもできます。(par_id3151042.8)

This function determines the attributes for a specified file and returns the bit pattern that can help you to identify the following file attributes:
この関数は、指定ファイルの属性を取得して、下記のファイル属性を示すビットパターンを返します。(par_id3161831.9)

(embed text/sbasic/shared/00000003.xhp#errorcode : linkinfo)

Error Codes

エラーコード(hd_id3152869.37)

(/embed text/sbasic/shared/00000003.xhp#errorcode)

(embed text/sbasic/shared/00000003.xhp#err5 : linkinfo)

5 Invalid procedure call
5 無効なプロシージャー呼び出しです (par_id3150891.41)

(/embed text/sbasic/shared/00000003.xhp#err5)

(embed text/sbasic/shared/00000003.xhp#err53 : linkinfo)

53 File not found
53 ファイルが見つかりません (par_id3151338.59)

(/embed text/sbasic/shared/00000003.xhp#err53)

Value
(hd_id3145364.10)

0 : Normal files.
0 : 通常のファイル。(par_id3147349.11)

1 : Read-only files.
1 : 読み取り専用のファイル。(par_id3147434.12)

8 : Returns the name of the volume
8 : ボリュームの名前を返す。(par_id3159154.15)

16 : Returns the name of the directory only.
16 : ディレクトリの名前のみを返す。(par_id3145271.16)

32 : File was changed since last backup (Archive bit).
32 : 前回のバックアップ時から変更のあったファイル (アーカイブビット)。(par_id3153953.17)

If you want to know if a bit of the attribute byte is set, use the following query method:
属性バイトの特定ビットがセットされているかは、下記のような処理で確認できます。(par_id3156444.18)

Example:
例:(hd_id3153094.19)

Sub ExampleSetGetAttr
Sub ExampleSetGetAttr(par_id3154491.20)

On Error Goto ErrorHandler REM Define target for error-handler
On Error Goto ErrorHandler REM エラーハンドラ用ターゲットを設定(par_id3155415.21)

If Dir("C:\test",16)="" Then MkDir "C:\test"
If Dir("C:\test",16)="" Then MkDir "C:\test"(par_id3154944.22)

If Dir("C:\test\autoexec.sav")="" THEN Filecopy "c:\autoexec.bat", "c:\test\autoexec.sav"
If Dir("C:\test\autoexec.sav")="" THEN Filecopy "c:\autoexec.bat", "c:\test\autoexec.sav"(par_id3151075.23)

SetAttr "c:\test\autoexec.sav" ,0
SetAttr "c:\test\autoexec.sav" ,0(par_id3149959.24)

Filecopy "c:\autoexec.bat", "c:\test\autoexec.sav"
Filecopy "c:\autoexec.bat", "c:\test\autoexec.sav"(par_id3153418.25)

SetAttr "c:\test\autoexec.sav" ,1
SetAttr "c:\test\autoexec.sav" ,1(par_id3149122.26)

print GetAttr( "c:\test\autoexec.sav" )
print GetAttr( "c:\test\autoexec.sav" )(par_id3154480.27)

end
End(par_id3150753.28)

ErrorHandler:
ErrorHandler:(par_id3150323.29)

Print Error
Print Error(par_id3154754.30)

end
End(par_id3155764.31)

end sub
end sub(par_id3156382.32)


< Prev / Next >